<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
ini_set('magic_quotes_gpc', 'Off');
ini_set('register_globals', 'Off');
ini_set('short_open_tag', 'On');
ini_set('zlib_output_compression', 'On');

set_include_path('.'
        . PATH_SEPARATOR . './library'
        . PATH_SEPARATOR . './application/models/'
        . PATH_SEPARATOR . get_include_path());

require_once 'Zend/Loader/Autoloader.php';

Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);

DEFINE('APPLICATION_PATH', realpath(dirname(__FILE__)));
DEFINE('ADN_VERSION', '0.2b');

$rootPath = dirname(APPLICATION_PATH);
$application = new Zend_Loader_Autoloader_Resource(array(
            'basePath' => APPLICATION_PATH . '/application/models/',
            'namespace' => '',
            'resourceTypes' => array('tables' => array('path' => 'Tables/', 'namespace' => 'Table'),
                'objects' => array('path' => 'Objects/', 'namespace' => 'Object'),
                'forms' => array('path' => 'Forms/', 'namespace' => 'Form')
                )));

$library = new Zend_Loader_Autoloader_Resource(array(
            'basePath' => $rootPath . '/Adn',
            'namespace' => 'Adn',
            'resourceTypes' => array('library' => array('path' => 'library/', 'namespace' => 'Library'),
                )));

Zend_Session::start();
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
$frontController->setParam('useDefaultControllerAlways', true);

Zend_Layout::startMvc(array('layoutPath' => './application/layouts'));
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->initView();
$viewRenderer->view->doctype('XHTML1_TRANSITIONAL');

try
{
    $configPath = './application/configuration/config.ini';
    $config = new Zend_Config_Ini($configPath, 'database');
    $db = Zend_Db::factory($config->database);
    $db->getConnection();
    Zend_Registry::set('pdo_mysql', $db);
    Zend_Db_Table::setDefaultAdapter($db);
    $registry = Zend_Registry::getInstance();
    $registry->set('adapter', $db);
} catch (zend_db_adapter_exception $e)
{
    echo 'Error : BDD';
    echo $e->getmessage();
}

$frontController->dispatch();
?>
